#include "common.h"

#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "util/intmap.h"
#include "tests/common_test.h"

static const struct sc_intmap_entry special_keys[] = {
    {1, 101},
    {2, 102},
    {3, 103},
    {4, 104},
    {5, 105},
    {6, 106},
    {7, 107},
    {8, 108},
    {9, 109},
    };

static void test_sc_intmap_find_entry(void){
    TEST_START_INFO;

    TEST_LINE_REPORT_START;

    // 注意，这里定义时不加const后报警告，但是忽略的情况下是可以编译通过并执行的
    const struct sc_intmap_entry *entry = sc_intmap_find_entry(special_keys, 7 ,5);
    assert(NULL!=entry);

    assert(105 == entry->value);
    printf("key=%d,value=%d\n", entry->key, entry->value);

    const struct sc_intmap_entry *entry2 = SC_INTMAP_FIND_ENTRY(special_keys,3);
    assert(103 == entry2->value);

    //printf("%d",entry2->value);
    TEST_END_INFO;
}

int main(int argc, char *argv[]) {
    (void) argc;
    (void) argv;

    test_sc_intmap_find_entry();

    return 0;
};